Import('env')
Import('env_vc9')
Import('env_vc9_x64')

# ---- ImageSequence.dll ----
is_env = env.Clone()

is_env['CPPDEFINES'] += ['_USRDLL', 'IMAGESEQUENCE_EXPORTS']
is_env['LIBS'] += ['gdiplus.lib', 'vfw32.lib']

target = 'ImageSequence'
is_env['PDB'] = target + '.pdb'
bin = is_env.SharedLibrary(
  target,
  [
    'ImageSequence.cpp',
  ]
)
env.Install('#/src/dist/bin', bin[0])

# TODO: Uncomment this once we fix image sequence export from 64 bit processes.
# Build the x64 version of ImageSequence.dll using VC9
"""
is_x64_env = env_vc9_x64.Clone()
is_x64_env['CPPDEFINES'].remove('UNICODE')
is_x64_env['CPPDEFINES'].remove('_UNICODE')
is_x64_env['CPPDEFINES'] += ['_MBCS', '_USRDLL', 'IMAGESEQUENCE_EXPORTS']
is_x64_env['LIBS'] += ['gdiplus.lib', 'vfw32.lib']
target = 'ImageSequence-x64'
is_x64_env['PDB'] = target + '.pdb'
bin = is_x64_env.SharedLibrary(
  target,
  [
    is_x64_env.Object('ImageSequence-x64', 'ImageSequence.cpp'),
  ]
)
env.Install('#/src/dist/bin', bin[0])
"""

# ---- fscommon.dll ----
fc_env = env.Clone()

fc_env['CPPDEFINES'] += ['_USRDLL']
fc_env['LINKFLAGS'] += ['/noentry']

target = 'fscommon'
fc_env['PDB'] = target + '.pdb'
bin = fc_env.SharedLibrary(
  target,
  [
    env.RES('fscommon.rc'),
  ]
)
env.Install('#/src/dist/bin', bin[0])

# ---- common.lib ----

# Build the MBCS version of the library
cpppath = ['..', '../dfsc', '../utils']
co_env = env.Clone()
co_env['CPPPATH'] = cpppath
co_env.Library(
  'common',
  [
    'autoupdate.cpp',
    'blankavi.cpp',
    'fscommon.cpp',
    '../utils/utils.cpp',
  ]
)

# Build the UNICODE version of the library using VC8
co_uni_env = env_vc9.Clone()
co_uni_env['CPPPATH'] = cpppath
co_uni_env['CPPDEFINES'] += ['UNICODE', '_UNICODE']
co_uni_env.Library(
  'common_unicode',
  [
    co_uni_env.Object('autoupdate-u', 'autoupdate.cpp'),
    co_uni_env.Object('blankavi-u', 'blankavi.cpp'),
    co_uni_env.Object('fscommon-u', 'fscommon.cpp'),
    co_uni_env.Object('utils-u', '../utils/utils.cpp'),
  ]
)

# Build the UNICODE x64 version of the library using VC9
co_x64_env = env_vc9_x64.Clone()
co_x64_env['CPPPATH'] = cpppath
co_x64_env['CPPDEFINES'] += ['UNICODE', '_UNICODE']
co_x64_env.Library(
  'common_unicode_x64',
  [
    co_x64_env.Object('autoupdate-u-x64', 'autoupdate.cpp'),
    co_x64_env.Object('blankavi-u-x64', 'blankavi.cpp'),
    co_x64_env.Object('fscommon-u-x64', 'fscommon.cpp'),
    co_x64_env.Object('utils-u-x64', '../utils/utils.cpp'),
  ]
)
